package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysSignLog;
import com.ruoyi.system.service.ISysSignLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 签到日志Controller
 * 
 * @author hlw
 * @date 2021-04-05
 */
@RestController
@RequestMapping("/system/signlog")
public class SysSignLogController extends BaseController
{
    @Autowired
    private ISysSignLogService sysSignLogService;

    /**
     * 查询签到日志列表
     */
    @PreAuthorize("@ss.hasPermi('system:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysSignLog sysSignLog)
    {
        startPage();
        List<SysSignLog> list = sysSignLogService.selectSysSignLogList(sysSignLog);
        return getDataTable(list);
    }

    /**
     * 导出签到日志列表
     */
    @PreAuthorize("@ss.hasPermi('system:log:export')")
    @Log(title = "签到日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysSignLog sysSignLog)
    {
        List<SysSignLog> list = sysSignLogService.selectSysSignLogList(sysSignLog);
        ExcelUtil<SysSignLog> util = new ExcelUtil<SysSignLog>(SysSignLog.class);
        return util.exportExcel(list, "log");
    }

    /**
     * 获取签到日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:log:query')")
    @GetMapping(value = "/{signId}")
    public AjaxResult getInfo(@PathVariable("signId") Long signId)
    {
        return AjaxResult.success(sysSignLogService.selectSysSignLogById(signId));
    }

    /**
     * 新增签到日志
     */
    @PreAuthorize("@ss.hasPermi('system:log:add')")
    @Log(title = "签到日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysSignLog sysSignLog)
    {
        return toAjax(sysSignLogService.insertSysSignLog(sysSignLog));
    }

    /**
     * 修改签到日志
     */
    @PreAuthorize("@ss.hasPermi('system:log:edit')")
    @Log(title = "签到日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysSignLog sysSignLog)
    {
        return toAjax(sysSignLogService.updateSysSignLog(sysSignLog));
    }

    /**
     * 删除签到日志
     */
    @PreAuthorize("@ss.hasPermi('system:log:remove')")
    @Log(title = "签到日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{signIds}")
    public AjaxResult remove(@PathVariable Long[] signIds)
    {
        return toAjax(sysSignLogService.deleteSysSignLogByIds(signIds));
    }
}
